home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / dev / e / eiffel.lha / flc / source / feature.e < prev    next >
Encoding:
Text File  |  1995-12-27  |  2.9 KB  |  112 lines

  1.  
  2. -> Copyright © 1995, Guichard Damien.
  3.  
  4. -> Eiffel features (most general class element)
  5.  
  6. -> Design decisions must be discussed here.
  7. -> The is_constant, is_variable, is_routine, ...  methods seem to be in
  8. -> contradiction with polymorphism as the type is directly tested.
  9. -> But most of validity contraints need this information and validity is
  10. -> linked with parsing, not with features. Here is an example, VDRS2:
  11. -> "That feature was not frozen and was not a constant attribute", so we must
  12. -> known wether a feature is frozen or not, even if all kinds of features can
  13. -> not be frozen. We must also check quickly if the feature is a constant.
  14. -> So beeing a constant or beeing frozen is a real feature of features.
  15.  
  16. -> TODO :
  17. ->   unique constants
  18. ->   routine redefinition to a variable attribute
  19. ->   preconditions
  20. ->   postconditions
  21. ->   external routines
  22. ->   feature merging
  23.  
  24. OPT MODULE
  25. OPT EXPORT
  26.  
  27. MODULE '*strings'
  28. MODULE '*treed_entity'
  29. MODULE '*class','*argument'
  30.  
  31. OBJECT feature OF treed_entity
  32.   class:PTR TO class   -> To be used by 'class' only
  33.   client:PTR TO class  -> Only one client
  34. ENDOBJECT
  35.  
  36. -> The class in which the feature has been added
  37. -> To be only used by class 'add_feature' method
  38. PROC set_class(class) OF feature
  39.   self.class:=class
  40. ENDPROC
  41.  
  42. -> Set count of the feature
  43. -> To be only used by class 'add_feature' method
  44. PROC set_count(x) OF feature IS EMPTY
  45.  
  46. -> Create a feature.
  47. PROC create(name,client,type) OF feature
  48.   self.int:=hash(name)
  49.   self.name:=name
  50.   self.client:=client
  51.   self.type:=type
  52. ENDPROC
  53.  
  54. -> Freeze this feature.
  55. PROC freeze() OF feature IS EMPTY
  56.  
  57. -> Is feature frozen?
  58. PROC is_frozen() OF feature IS FALSE
  59.  
  60. -> Is feature deferred?
  61. PROC is_deferred() OF feature IS FALSE
  62.  
  63. -> Has feature this final name in the class?
  64. -> Use connected with feature renaming (see unnamer)
  65. PROC has_final_name() OF feature IS TRUE
  66.  
  67.  
  68. -> Is feature an attribute?
  69. PROC is_attribute() OF feature IS FALSE
  70.  
  71. -> Is feature a constant attribute?
  72. PROC is_constant() OF feature IS FALSE
  73.  
  74. -> Is feature a variable attribute?
  75. PROC is_variable() OF feature IS FALSE
  76.  
  77. -> Is feature a routine?
  78. PROC is_routine() OF feature IS FALSE
  79.  
  80. -> Is feature a procedure?
  81. PROC is_procedure() OF feature IS FALSE
  82.  
  83. -> Is feature a function?
  84. PROC is_function() OF feature IS FALSE
  85.  
  86.  
  87. -> Make a copy renamed with 'name'
  88. PROC rename(name) OF feature
  89. ENDPROC
  90.  
  91. -> Make a copy exported to 'client'
  92. PROC new_exports(client) OF feature
  93. ENDPROC
  94.  
  95. -> Make an undefined copy.
  96. PROC undefine() OF feature
  97. ENDPROC
  98.  
  99. -> Make a copy redefined with 'client','arguments','type'
  100. PROC redefine(client,arguments,type) OF feature
  101. ENDPROC
  102.  
  103. -> Is signature conform to feature signature
  104. PROC is_conform(arguments:PTR TO argument,type:PTR TO class) OF feature
  105.   DEF result:PTR TO class
  106.   IF arguments THEN RETURN FALSE
  107.   IF type=NIL THEN RETURN self.type=NIL
  108.   IF self.type=NIL THEN FALSE
  109.   result:=type.base()
  110. ENDPROC result.is_heir_of(self.type.base())
  111.  
  112.